<!DOCTYPE html>
<html>
	<head>
		<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3419308738737930"
		     crossorigin="anonymous"></script>
			 <meta name="description" content="千千万能工具箱，在线markdown，markdown编辑器，云笔记">
			 <meta name="keywords" content="编辑器,markdown,IT_迁哥,云笔记">
			 <meta name="robots" content="index, follow">
			   
			 <meta name="author" content="IT_迁哥">
		<meta charset="utf-8">
		<title>千千万能工具箱-在线markdown笔记</title>
		<link rel="stylesheet" href="../js/element2.4.7/index.css" />
		<script src="../js/vue2.6.11/vue.js"></script>
		<script src="../js/element2.4.7/index.js"></script>
		<script src="../js/jquery.min.js"></script>
		<script src="template.js"></script>

		<style>
			.login {
				width: 25%;
				position: fixed;
				left: 38%;
				top: 30%;
				opacity: 0.8;
				/* height: 300px; */
			}
		</style>
	</head>
	<body style="overflow-y: hidden;">
		<div id="app">
			<iframe :src="iframeSrc" style="width: 100%;height: 1000px; border: 0px;"></iframe>
			<div class="login" v-loading="loginShow">
				<el-card class="box-card">
					<div slot="header" class="clearfix">
						<span style="font-size: 18px; font-weight: bold;">千千万能工具-在线markdown笔记</span>
						<!-- <span style="float: right; " type="text">登录</span> -->
					</div>
					<el-row>
						<el-col :span="18">
							<el-input v-model="input" placeholder="请输入密钥" :clearable="true"></el-input>
						</el-col>

					</el-row>
					<br />
					<el-row>
						<el-col :span="20">
							<el-button type="primary" size="small" @click="login()">登录笔记</el-button>
						</el-col>
						<el-col :span="4">
							<el-button type="text" size="small" style="color: lightslategray;"
								@click="openFindKeyDig()">找回密钥</el-button>
						</el-col>
					</el-row>
					<br />
					<el-row>
						<el-col :span="20"><a href="/"
								style="font-size: 13px; text-decoration: none; color: black;">返回主站</a></el-col>
						<el-col :span="4"><span
								style="font-size: 13px; text-decoration: none; color: blue;cursor: pointer;"
								@click="openRegisterDig()">注册密钥</span></el-col>

					</el-row>
				</el-card>
			</div>
<div style="opacity: 1;">
			<el-dialog v-loading="registerShow" title="注册密钥" :visible.sync="registerDig" width="30%" :modal="false"
				:close-on-click-modal="false" top="22vh">
				<el-input v-model="info.email" placeholder="请输入邮箱" style="width: 60%;"></el-input>
				</br>
				</br>
				<el-input type="text" v-model="info.nickname" placeholder="请输入昵称(最大长度10)" style="width: 60%;"
					maxlength="10"></el-input>
				<span slot="footer" class="dialog-footer">
					<el-button @click="registerDig = false">取 消</el-button>
					<el-button type="primary" @click="register()">注册密钥 </el-button>
				</span>
			</el-dialog>
</div>
<div style="opacity: 1;">
			<el-dialog v-loading="findKeyShow" title="找回密钥" :visible.sync="findKeyDig" width="30%" :modal="false"
				:close-on-click-modal="false" top="22vh">
				<el-row>
					<el-col :span="14">
						<el-input v-model="find.email" placeholder="请输入邮箱"></el-input>
					</el-col>
					<el-col :span="7" :offset="1">
						<el-button style="color: lightslategray;" :disabled="smsDisable" @click="sendSms()">{{smsText}}
						</el-button>
					</el-col>
				</el-row>

				</br>
				</br>
				<el-row>
					<el-col :span="14">
						<el-input type="text" v-model="find.code" placeholder="请输入验证码" maxlength="6"></el-input>

					</el-col>
				</el-row>
				<span slot="footer" class="dialog-footer">
					<el-button @click="findKeyDig = false">取 消</el-button>
					<el-button type="primary" @click="equalsCode()">找回密钥 </el-button>
				</span>
			</el-dialog>
</div>
		</div>
	</body>
	<script>
			const baseUrl = "https://api.lqcpws.cn"
		var app = new Vue({
			el: '#app',
			data: {
				title: '登录',
				input: "",
				white: "https://www.lqcpws.cn/se/src/cloud/",
				black: "https://www.lqcpws.cn/se/src/cloud-and-rain/",
				iframeSrc: "",
				registerDig: false,
				registerShow: false,
				findKeyDig: false,
				findKeyShow: false,
				loginShow: false,
				find: {
					email: "",
					code: ""
				},
				smsText: "发送验证码",
				smsTime: 60,
				smsTimer: undefined,
				smsDisable: false,
				info: {
					email: "",
					nickname: ""
				}
			},
			methods: {
				login() {
					if (this.input.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '密钥不能为空！',
							duration: 2000,
						});
						return
					}
					let _this = this
					this.loginShow = true
					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdUser/login',
						data: {
							key: _this.input
						},
						success: function(res) {
							_this.loginShow = false
							if (res.code == 200) {

                     	_this.$alert('亲爱的朋友，欢迎回来！', '登录成功！', {
									confirmButtonText: '确定',
									callback: action => {
										localStorage.setItem("mdToken",res.data)
										window.location.href='home.html'
									}
								});
								


							} else {
								_this.$notify.error({
									title: '警告',
									message: res.msg,
									duration: 5000,
									dangerouslyUseHTMLString: true,
								});
							}
						}
					})
				},
				openFindKeyDig() {
					this.findKeyDig = true
					this.find.email = ""
					this.find.code = ""
				},
				equalsCode() {
					if (this.find.email.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '邮箱不能为空！',
							duration: 2000,
						});
						return
					}
					if (this.find.code.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '验证码不能为空！',
							duration: 2000,
						});
						return
					}

					let _this = this
					this.findKeyShow = true
					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdUser/equalsKey',
						data: {
							email: _this.find.email,
							code: _this.find.code
						},
						success: function(res) {
							_this.findKeyShow = false
							if (res.code == 200) {
								_this.$alert('你的密钥为:' + res.data, '找回密钥成功,请妥善保存密钥', {
									confirmButtonText: '确定',
									callback: action => {
										_this.findKeyDig = false
									}
								});


							} else {
								_this.$notify.error({
									title: '警告',
									message: res.msg,
									duration: 2000,
								});
							}
						}
					})

				},
				sendSms() {
					if (this.find.email.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '邮箱不能为空！',
							duration: 2000,
						});
						return
					}
					let _this = this
					$.ajax({
						type: 'post',
						url: baseUrl + '/md/mdUser/findKey',
						data: {
							email: _this.find.email
						},
						success: function(res) {
							_this.smsDisable = true
							if (res.code == 200) {
								_this.$notify({
									title: '提示',
									message: res.msg,
									duration: 2000,
									type: 'success',
								});

								_this.smsTimer = setInterval(function(that) {
									if (that.smsTime == 0) {
										clearInterval(that.smsTimer)
										that.smsTime = 60
										that.smsText = "发送验证码"
										that.smsDisable = false
										return;
									}
									that.smsTime--
									that.smsText = "发送验证码" + that.smsTime

								}, 1000, _this)


							} else {
								_this.$notify.error({
									title: '警告',
									message: res.msg,
									duration: 2000,
								});
							}
						}
					})

				},
				openRegisterDig() {
					this.registerDig = true
					this.info.email = ""
					this.info.nickname = ""
				},
				register() {
					if (this.info.email.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '邮箱不能为空！',
							duration: 2000,
						});
						return
					}
					if (this.info.nickname.trim() == "") {
						this.$notify.error({
							title: '警告',
							message: '昵称不能为空！',
							duration: 2000,
						});
						return
					}
					this.registerShow = true
					let _this = this
					$.ajax({
						type: 'post',
						contentType: 'application/json;charset=utf-8',
						url: baseUrl + '/md/mdUser/register',
						data: JSON.stringify(_this.info),
						success: function(res) {
							_this.registerShow = false
							if (res.code == 200) {
								_this.$alert('你的密钥为:' + res.data, '注册成功,请妥善保存密钥', {
									confirmButtonText: '确定',
									callback: action => {
										_this.registerDig = false
									}
								});
							} else {
								_this.$notify.error({
									title: '警告',
									message: '注册失败,' + res.msg,
									duration: 2000,
								});
							}
						}
					})
				},
				requestCount() {
					// let ys=	LZString.compressToBase64(JSON.stringify(nes.toJSON()))
					// 	console.log(JSON.parse(LZString.decompressFromBase64(ys)))
					let _this = this
					$.ajax({
						type: 'get',
						url: baseUrl + "/pc/requestCountByDay",
						success: function(res) {


						}


					})

				},
				loadTemplate(data) {
					let str = templateStr
					str = str.replaceAll("{{title}}", data.title)
					str = str.replaceAll("{{mdText}}", data.mdText)
					str = str.replaceAll("{{watermark}}", data.watermark)

					return str;

				},
				checkStatus(){
				const mdToken=	localStorage.getItem("mdToken")
				if(mdToken!=undefined&&mdToken!=""){
					window.location.href='home.html'
				}
				},


			},
			mounted() {
				this.checkStatus()
				let temp = {
					title: "爱你",
					mdText: "### 你好",
					watermark: true
				}

				// console.log(this.loadTemplate(temp))
				// console.log(templateStr)
				this.requestCount()
				let h = new Date().getHours();
				if (h >= 6 && h < 18) {
					this.iframeSrc = this.white
				} else {
					this.iframeSrc = this.black
				}
				this.$notify({
					title: '提示',
					message: '1：本站永久免费<br/>' +
						'2：请不要发布有关政治，色情，暴力的内容，违者封号<br/>' +
						'3：不要随意借账号给别人，数据会有风险<br/>' +
						'4：感谢editor.md',
					dangerouslyUseHTMLString: true,
					duration: 10000,
					type: 'warning'
				});
			}
		})
	</script>
</html>
